package com.chartboost.sdk.impl;

import android.app.Activity;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.BaseAdapter;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import java.util.ArrayList;
import java.util.List;

public class q
{
  private ScrollView a;
  private HorizontalScrollView b;
  private ViewGroup c;
  private LinearLayout d;
  private BaseAdapter e;
  private List<List<View>> f;
  private List<List<View>> g;
  private List<Integer> h;
  private int i;
  private DataSetObserver j = new DataSetObserver()
  {
    public void onChanged()
    {
      int i = q.a(q.this).getChildCount();
      int k;
      int m;
      for (int j = 0; ; j++)
      {
        if (j >= i)
        {
          q.c(q.this).clear();
          q.a(q.this).removeAllViews();
          k = q.e(q.this).getCount();
          m = 0;
          if (m < k)
            break;
          q.a(q.this).requestLayout();
          return;
        }
        List localList1 = (List)q.b(q.this).get(((Integer)q.c(q.this).get(j)).intValue());
        List localList2 = (List)q.d(q.this).get(((Integer)q.c(q.this).get(j)).intValue());
        View localView1 = q.a(q.this).getChildAt(j);
        localList1.remove(localView1);
        localList2.add(localView1);
      }
      int n = q.e(q.this).getItemViewType(m);
      List localList3 = (List)q.b(q.this).get(n);
      List localList4 = (List)q.d(q.this).get(n);
      q.c(q.this).add(Integer.valueOf(n));
      boolean bool = localList4.isEmpty();
      View localView2 = null;
      if (!bool)
      {
        localView2 = (View)localList4.get(0);
        localList4.remove(0);
      }
      View localView3 = q.e(q.this).getView(m, localView2, q.a(q.this));
      localList3.add(localView3);
      if (q.f(q.this) == 0);
      for (LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-2, -1); ; localLayoutParams = new LinearLayout.LayoutParams(-1, -2))
      {
        if (m < k - 1)
          localLayoutParams.setMargins(0, 0, 0, 1);
        q.a(q.this).addView(localView3, localLayoutParams);
        m++;
        break;
      }
    }
  };

  public q(Context paramContext, int paramInt)
  {
    this.d = new LinearLayout(paramContext);
    this.i = paramInt;
    this.d.setOrientation(paramInt);
    if (paramInt == 0);
    for (this.c = a(paramContext); ; this.c = b(paramContext))
    {
      this.c.addView(this.d);
      this.f = new ArrayList();
      this.g = new ArrayList();
      this.h = new ArrayList();
      this.d.setOnTouchListener(new View.OnTouchListener()
      {
        public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
        {
          try
          {
            View localView = ((Activity)q.a(q.this).getContext()).getCurrentFocus();
            if (localView != null)
              ((InputMethodManager)q.a(q.this).getContext().getSystemService("input_method")).hideSoftInputFromWindow(localView.getApplicationWindowToken(), 0);
            return false;
          }
          catch (Exception localException)
          {
          }
          return false;
        }
      });
      return;
    }
  }

  private HorizontalScrollView a(Context paramContext)
  {
    if (this.b == null)
    {
      this.b = new HorizontalScrollView(paramContext);
      this.b.setFillViewport(true);
    }
    return this.b;
  }

  private ScrollView b(Context paramContext)
  {
    if (this.a == null)
    {
      this.a = new ScrollView(paramContext);
      this.a.setFillViewport(true);
    }
    return this.a;
  }

  private Context d()
  {
    return this.d.getContext();
  }

  public ViewGroup a()
  {
    return this.c;
  }

  public void a(int paramInt)
  {
    if (paramInt != this.i)
    {
      this.i = paramInt;
      this.d.setOrientation(paramInt);
      this.c.removeView(this.d);
      if (paramInt != 0)
        break label60;
    }
    label60: for (this.c = a(d()); ; this.c = b(d()))
    {
      this.c.addView(this.d);
      return;
    }
  }

  public void a(BaseAdapter paramBaseAdapter)
  {
    if (this.e != null)
      this.e.unregisterDataSetObserver(this.j);
    this.e = paramBaseAdapter;
    this.e.registerDataSetObserver(this.j);
    this.d.removeAllViews();
    this.f.clear();
    this.g.clear();
    for (int k = 0; ; k++)
    {
      if (k >= this.e.getViewTypeCount())
      {
        this.h.clear();
        this.e.notifyDataSetChanged();
        return;
      }
      this.f.add(new ArrayList());
      this.g.add(new ArrayList());
    }
  }

  public LinearLayout b()
  {
    return this.d;
  }

  public void c()
  {
    if ((this.c == this.a) && (this.a != null))
      this.a.fullScroll(130);
    while ((this.c != this.b) || (this.b == null))
      return;
    this.b.fullScroll(66);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.impl.q
 * JD-Core Version:    0.6.2
 */